---
title: Update Page Annotation
description: Learn how to modify an existing annotation on a PDF page.
searchable: true
---

# updatePageAnnotation

Modifies an existing annotation on a specific page.

## Signature

```typescript
updatePageAnnotation(
  doc: PdfDocumentObject,
  page: PdfPageObject,
  annotation: PdfAnnotationObject
): PdfTask<boolean>;
````

## Description

This method finds an existing annotation by its **`id`** and updates its properties with the values from the provided `annotation` object. This allows you to change an annotation's position, color, content, or any other attribute.

Like `createPageAnnotation`, this modifies the document in memory. Use `saveAsCopy` to generate a file with the changes.

## Parameters

| Name | Type | Description |
| :--- | :--- | :--- |
| **`doc`** | `PdfDocumentObject` | The handle of the document to modify. |
| **`page`** | `PdfPageObject` | The page where the annotation exists. |
| **`annotation`** | `PdfAnnotationObject` | The **modified annotation object**. It must have the same `id` as the annotation you wish to update. |

## Returns

`PdfTask<boolean>`

A **`Task`** that resolves with `true` if the annotation was successfully found and updated.

## Example

```typescript
// Assuming 'engine', 'document', and 'page' are available

async function changeAnnotationColor(annotation) {
  // Create a modified copy of the annotation
  const updatedAnnotation = {
    ...annotation,
    color: '#FF0000', // Change color to red
    rect: { // Also move it
      ...annotation.rect,
      origin: { x: annotation.rect.origin.x, y: annotation.rect.origin.y + 10 }
    }
  };

  try {
    const success = await engine.updatePageAnnotation(document, page, updatedAnnotation).toPromise();
    if (success) {
      console.log(`Annotation ${annotation.id} was updated.`);
      // Re-render the page or just the annotation to see the change
    }
  } catch (error) {
    console.error('Failed to update annotation:', error);
  }
}
```

## See Also

  - [Create Page Annotations](./create-page-annotation.md)
  - [Remove Page Annotations](./remove-page-annotation.md)